package com.dingwen.treasure.core.controller;

import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.base.util.EnumUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 　EnumController
 * 　@author dingwen
 * 　@date 2022/6/29
 */
@Api(tags = "枚举统一翻译接口")
@RestController
@Slf4j
@RequestMapping("enum")
@RequiredArgsConstructor
public class EnumController {

    @ApiOperation(value = "获取枚举翻译信息", response = Result.class)
    @ApiImplicitParam(name = "enumClassName", value = "枚举类简单名称", paramType = "query")
    @GetMapping()
    @SneakyThrows(Throwable.class)
    public List<Object> getEnums(@RequestParam(required = false) String enumClassName) {
        return EnumUtil.getEnumMap(enumClassName);
    }
}
